package com.briup.day14;

import java.util.ArrayList;
import java.util.Collection;

public class Test_Element {
    public static void main(String[] args) {
        Collection<String> c1=new ArrayList<>();
        Collection<String> c2=new ArrayList<>();
        String s1="hello";
        String s2="world";
        c1.add(s1);
        c1.add(s2);
        String s3="hello";
        String s4="nihao";
        String s5="okok";
        c2.add(s3);
        c2.add(s4);
        c2.add(s5);
        System.out.println(c1);
        System.out.println(c2);
        c1.addAll(c2);
        System.out.println(c1);
        boolean f=c1.contains("hello");
        System.out.println(f);
        String s6=new String("hello");
        f=c1.contains(s6);//contains借助equals方法进行比较
        System.out.println(f);
        System.out.println(c1.containsAll(c2));
        System.out.println("------------------------------");
        f=c1.remove(s6);
        System.out.println(f);
        System.out.println(c1);
        System.out.println("------------------------------");
//        removeall将指定的集合整个删除
        c1.removeAll(c2);
        System.out.println(f+" after remove c2"+c1);


    }
}
